package com.sunwoda.springbootredis.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * 类描述：
 *
 * @ClassName Application
 * @Description TODO
 * @Author shiguorang
 * @Date 2021/9/22 19:19
 * @Version 1.0
 */
//@Component
public class ApplicationContextUtil implements ApplicationContextAware {

    public static ApplicationContext applicationContext;
    @Override
    public void setApplicationContext(ApplicationContext context) throws BeansException {
        applicationContext = context;
    }

    public static Object getBean(String beanName){
        return applicationContext.getBean(beanName);
    }
}
